<template>
	<div class="app-container">
		<el-form class="search-form">
			<el-form-item class="form-button-bar">
				<!-- <el-button @click="addHotList" type="success">加入热点</el-button> -->
				<el-button @click="handleDeleteList" type="danger">归档事件</el-button>
				<el-button plain class="search-bar-button" style="float: right;border-width: 2px" type="primary" @click="searchBarVisable = !searchBarVisable">{{searchBarVisable?'收起':'展开'}}搜索项<i
					 :class="searchBarVisable?'el-icon-caret-top':'el-icon-caret-bottom'"></i></el-button>
			</el-form-item>
		</el-form>
		<el-form class="search-form" label-width="80px">
			<div :class="searchBarVisable?'':'search-bar-hide'" style="transition:  all .3s ease-in-out;">
				<el-form-item label="标题">
					<el-input style="width: 450px;" clearable v-model.trim="listQuery.eventTitle" placeholder="请输入搜索内容"></el-input>
				</el-form-item>
        <el-form-item label="标签">
        	<el-input style="width: 450px;" clearable v-model.trim="listQuery.keyword" placeholder="请输入搜索内容"></el-input>
        </el-form-item>
				<el-form-item label="事件状态">
					<el-radio v-model="listQuery.dataStatus" label="" border size="mini">全部</el-radio>
					<el-radio v-model="listQuery.dataStatus" label="0" border size="mini">正常</el-radio>
					<el-radio v-model="listQuery.dataStatus" label="2" border size="mini">已归档</el-radio>
				</el-form-item>
				<el-form-item label="审核状态">
					<el-radio v-model="listQuery.adjustStatus" label="" border size="mini">全部</el-radio>
					<el-radio v-model="listQuery.adjustStatus" label="0" border size="mini">未审核</el-radio>
					<el-radio v-model="listQuery.adjustStatus" label="1" border size="mini">已审核</el-radio>
				</el-form-item>
				<el-form-item label="更新时间">
					<el-radio v-model="listQuery.chooseTime" label="" border size="mini">自定义</el-radio>
					<el-radio v-model="listQuery.chooseTime" label="1" border size="mini">今天</el-radio>
					<el-radio v-model="listQuery.chooseTime" label="3" border size="mini">近三天</el-radio>
				</el-form-item>
				<el-form-item label="">
					<el-date-picker :clearable="true" type="datetimerange" :default-time="['00:00:00', '23:59:59']" @change="listQuery.chooseTime = ''"
					 @keyup.enter.native="getList" style="width: 450px;" class="filter-item" range-separator="至" start-placeholder="开始日期"
					 end-placeholder="结束日期" v-model="updateTime">
					</el-date-picker>
				</el-form-item>
				<el-form-item label="审核时间">
					<el-radio v-model="listQuery.chooseTime2" label="" border size="mini">自定义</el-radio>
					<el-radio v-model="listQuery.chooseTime2" label="1" border size="mini">今天</el-radio>
					<el-radio v-model="listQuery.chooseTime2" label="3" border size="mini">近三天</el-radio>
				</el-form-item>
				<el-form-item label="">
					<el-date-picker :clearable="true" type="datetimerange" :default-time="['00:00:00', '23:59:59']" @change="listQuery.chooseTime2 = ''"
					 @keyup.enter.native="getList" style="width: 450px;" class="filter-item" range-separator="至" start-placeholder="开始日期"
					 end-placeholder="结束日期" v-model="publishTime">
					</el-date-picker>
				</el-form-item>
				<el-form-item label="热度">
					<el-rate style="line-height: 45px;" v-model="listQuery.eventHot" void-icon-class="el-icon-aliFirefire"
					 disabled-void-icon-class="el-icon-aliFirefire" :colors="['#d81e06', '#d81e06', '#d81e06']" :icon-classes="['el-icon-aliFirefire-fill', 'el-icon-aliFirefire-fill','el-icon-aliFirefire-fill']">
					</el-rate>
				</el-form-item>
				<el-form-item>
					<el-button type="primary" icon="el-icon-search" @click="getList">{{$t('table.search')}}</el-button>
					<el-button @click="resetForm">重置</el-button>
				</el-form-item>
			</div>
		</el-form>

		<el-table :key='tableKey' :data="list" v-loading="listLoading" element-loading-text="加载中..." border fit
		 highlight-current-row @selection-change="handleSelectionChange" style="width: 100%">
			<el-table-column align="center" type="selection" width="55"></el-table-column>
			<el-table-column align="center" label="事件名称" min-width="100">
				<template slot-scope="scope">
					<el-button class="preview-button" type="text" @click="handleShow(scope.row, true)">{{scope.row.eventTitle}}</el-button>
				</template>
			</el-table-column>
			<el-table-column label="相关新闻" align="center" min-width="200">
				<template slot-scope="scope">
					<p v-for="(item, index) in scope.row.listNews" style="text-align: left;">{{ index + 1 }}.{{ item }}</p>
				</template>
			</el-table-column>
			<el-table-column label="事件标签" align="center" min-width="100">
				<template slot-scope="scope">
					<el-tag v-for="(tag, index) in scope.row.listTags" :key="tag.keyword" size="small">{{ tag.keyword }}</el-tag>
				</template>
			</el-table-column>
			<el-table-column align="center" label="审核状态">
				<template slot-scope="scope">
					<el-tag size="small" :type="formatClass(scope.row.adjustStatus)">{{formatStatu(scope.row.adjustStatus)}}</el-tag>
				</template>
			</el-table-column>
			<el-table-column prop="updater" label="审核人" align="center"></el-table-column>
			<el-table-column prop="adjustTime" label="审核时间" align="center" width="100"></el-table-column>
			<el-table-column prop="updatetime" label="更新时间" align="center" width="100"></el-table-column>
			<el-table-column align="center" label="事件状态">
				<template slot-scope="scope">
					<el-tag size="small" :type="stateColor(scope.row.dataStatus)">{{stateFont(scope.row.dataStatus)}}</el-tag>
				</template>
			</el-table-column>
			<el-table-column label="热度" align="center" width="140">
				<template slot-scope="scope">
					<el-rate v-model="scope.row.eventHot" disabled void-icon-class="el-icon-aliFirefire" disabled-void-icon-class="el-icon-aliFirefire"
					 :colors="['#d81e06', '#d81e06', '#d81e06']" :icon-classes="['el-icon-aliFirefire-fill', 'el-icon-aliFirefire-fill','el-icon-aliFirefire-fill']">
					</el-rate>
				</template>
			</el-table-column>
			<el-table-column label="操作" align="center" width="150">
				<template slot-scope="scope">
					<el-button size="mini" @click="handleShow(scope.row, false)" v-loading.fullscreen.lock="fullscreenLoading"
					 element-loading-text="数据更新中 按Esc退出" element-loading-spinner="el-icon-loading" element-loading-background="rgba(0, 0, 0, 0.2)"
					 v-if="scope.row.dataStatus == 0">编辑</el-button>
					<el-button v-if="scope.row.dataStatus == 0" size="mini" type="danger" @click="handleDelete(scope.row)" :disabled="scope.row.adjustStatus == 0">归档</el-button>
					<el-button v-else size="mini" type="danger" @click="dataStatusChange(scope.row)">取消归档</el-button>
				</template>
			</el-table-column>
		</el-table>
		<div class="pagination-container">
			<el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page.sync="listQuery.pageNum"
			 :page-sizes="[10,20,30, 50]" :page-size="listQuery.pageSize" layout="total, sizes, prev, pager, next, jumper"
			 :total="total">
			</el-pagination>
		</div>

		<el-dialog :fullscreen='true' :title="dialogStatus ? '已知事件详情': '已知事件编辑'" :visible.sync="dialogFormVisible">
			<el-form :rules="rules" ref="dataForm" :model="temp" label-position="left" label-width="130px" style='margin: auto; max-width: 1200px'>
				<el-row :gutter="24">
					<el-col :span="12">
						<el-form-item label="事件名称" prop="eventTitle">
							<el-input :readonly='dialogStatus' v-model.trim="temp.eventTitle" type="text" placeholder="请输入"></el-input>
						</el-form-item>
					</el-col>
					<el-col :span="10">
						<el-form-item label="事件生命周期" prop="originTime">
							<el-date-picker disabled v-model="temp.originTime" type="datetime" placeholder=""></el-date-picker>
						</el-form-item>
					</el-col>
					<el-col :span="2">
						<span style="line-height: 39px;">——至今</span>
					</el-col>

					<el-col :span="12">
						<el-form-item label="审核模式" prop="adjustModel">
							<el-select v-model="temp.adjustModel" placeholder="请选择" :disabled='dialogStatus'>
								<el-option label="自动审核" :value="1"></el-option>
								<el-option label="手动审核" :value="0"></el-option>
							</el-select>
						</el-form-item>
					</el-col>
					<!--<el-col :span="12">
						<el-form-item label="事件类型" prop="sjStyle">
							<el-input disabled v-model="temp.sjStyle"></el-input>
						</el-form-item>
					</el-col>
					<el-col :span="12">
						<el-form-item label="热点推送群体" prop="tsqt">
							<el-input disabled v-model="temp.tsqt"></el-input>
						</el-form-item>
					</el-col> -->
					<el-col :span="12">
						<el-form-item label="事件热度" prop="eventHot">
							<el-rate style="line-height: 45px;" v-model="temp.eventHot" disabled void-icon-class="el-icon-aliFirefire"
							 disabled-void-icon-class="el-icon-aliFirefire" :colors="['#d81e06', '#d81e06', '#d81e06']" :icon-classes="['el-icon-aliFirefire-fill', 'el-icon-aliFirefire-fill','el-icon-aliFirefire-fill']">
							</el-rate>
						</el-form-item>
					</el-col>
					<el-col :span="24">
						<el-form-item label="事件标签">
							<el-select
								:disabled='dialogStatus'
								multiple
								:multiple-limit=5
								filterable
								remote
								reserve-keyword
								:remote-method="remoteMethod"
								:loading="searchloading"
								popper-class="select-rule"
								no-match-text="暂无信息"
								no-data-text="暂无信息"
								:default-first-option=true
								v-model="temp.listTags"
								@change="selectShange"
								placeholder="请选择">
								<el-option v-for="(item, index) in tagOptions" :key="item" :label="item" :value="item"></el-option>
							</el-select>
						</el-form-item>
					</el-col>
					<!--<el-col :span="3">
			    	<el-button v-if='!dialogStatus' type="primary" v-loading="updateBtnLoading" @click="evtUpdateMethod">更新资讯</el-button>
				  </el-col>-->
					<el-col :span="24">
						<el-form-item label="相关产业链">
							<el-select v-model="temp.relatedChain" multiple filterable placeholder="请选择" :disabled='dialogStatus'>
							<el-option v-for="item in flowChartList" :key="item" :label="item" :value="item"></el-option>
							</el-select>
						</el-form-item>
					</el-col>
					<el-col :span="24">
						<el-form-item label="事件描述" prop="eventDescript">
							<el-input :readonly='dialogStatus' v-model="temp.eventDescript" type="textarea" :rows="5" placeholder="请输入"></el-input>
						</el-form-item>
					</el-col>
					<el-col :span="24">
						<el-form-item label="历史新闻">
							<!-- :height="temp.listNewsInfoSc.length > 3 ? 500 : 0" -->
							<el-table stripe :height="500" :data="temp.listNewsInfoSc" style="width: 100%"
							 border fit highlight-current-row v-loading="tempListLoading01">
								<el-table-column type="index" width="40" align="center"></el-table-column>
								<el-table-column label="标题" align="center" min-width="200">
								<template slot-scope="scope">
									<el-button class="preview-button" type="text" @click="showInfo(scope.row)">{{scope.row.title}}</el-button>
								</template>
								</el-table-column>
								<el-table-column prop="summary" label="摘要" align="center" min-width="300"></el-table-column>
								<el-table-column prop="createTime" label="创建时间" align="center" width="100"></el-table-column>
								<el-table-column prop="updateTime" label="更新时间" align="center" width="100"></el-table-column>
								<el-table-column prop="source" label="来源" align="center"></el-table-column>
								<el-table-column label="态度" align="center" width="65">
									<template slot-scope="scope">
										<span v-if="scope.row.attitude == -1" class="tagColor" style="background-color: #4cba2a;">&nbsp;利空&nbsp;</span>
										<span v-else-if="scope.row.attitude == 0" class="tagColor" style="background-color: #c5d106;">&nbsp;中性&nbsp;</span>
										<span v-else="scope.row.attitude == 1" class="tagColor" style="background-color: red;">&nbsp;利好&nbsp;</span>
									</template>
								</el-table-column>
								<el-table-column align="center" label="操作" width="150" class-name="small-padding fixed-width" v-if='!dialogStatus'>
									<template slot-scope="scope">
										<!-- <el-button style="width: auto" type="danger" size="mini" @click.native.prevent="deleteRow(scope.$index, temp.listNewsInfoSc)">移除</el-button> -->
										<el-button style="width: auto" type="danger" size="mini" @click.native.prevent="deleteNews(scope.row)">移除</el-button>
									</template>
								</el-table-column>
							</el-table>
							<div class="pagination-container" style="margin-top: 10px;">
								<el-pagination background @size-change="newsSizeChange" @current-change="newsCurrentChange" :current-page.sync="newsObj.pageNum" :page-sizes="[10, 20, 30, 50]" :page-size="newsObj.pageSize" layout="total, sizes, prev, pager, next, jumper" :total="newsTotal"></el-pagination>
							</div>
						</el-form-item>
					</el-col>
					<el-col :span="24">
						<el-form-item label="相关资讯">
							<!-- :height="temp.listNewsInfo.length > 3 ? 500 : 0" -->
							<el-table stripe :height="500" :data="temp.listNewsInfo" style="width: 100%"
							 border fit highlight-current-row v-loading="tempListLoading02">
								<el-table-column type="index" width="40" align="center"></el-table-column>
								<el-table-column label="标题" align="center" min-width="200">
									<template slot-scope="scope">
										<el-button class="preview-button" type="text" @click="showInfo(scope.row)">{{scope.row.title}}</el-button>
									</template>
								</el-table-column>
								<el-table-column prop="summary" label="摘要" align="center" min-width="300"></el-table-column>
								<el-table-column prop="createTime" label="创建时间" align="center" width="100"></el-table-column>
								<el-table-column prop="updateTime" label="更新时间" align="center" width="100"></el-table-column>
								<el-table-column prop="source" label="来源" align="center"></el-table-column>
								<el-table-column label="态度" align="center" width="65">
									<template slot-scope="scope">
										<span v-if="scope.row.attitude == -1" class="tagColor" style="background-color: #4cba2a;">&nbsp;利空&nbsp;</span>
										<span v-else-if="scope.row.attitude == 0" class="tagColor" style="background-color: #c5d106;">&nbsp;中性&nbsp;</span>
										<span v-else="scope.row.attitude == 1" class="tagColor" style="background-color: red;">&nbsp;利好&nbsp;</span>
									</template>
								</el-table-column>
							</el-table>
							<div class="pagination-container" style="margin-top: 10px;">
								<el-pagination background @size-change="stocksSizeChange" @current-change="stocksCurrentChange" :current-page.sync="stocksObj.pageNum" :page-sizes="[10, 20, 30, 50]" :page-size="stocksObj.pageSize" layout="total, sizes, prev, pager, next, jumper" :total="stocksTotal"></el-pagination>
							</div>
						</el-form-item>
					</el-col>
					<el-col :span="24">
						<el-form-item label="相关股票">
							<el-button v-if='!dialogStatus' style="margin-bottom: 12px;" @click="handleSelect()" type="success" icon="el-icon-plus">添加股票</el-button>
							<!-- temp.listStockSc.length > 7 ? 530 : 0 -->
							<el-table stripe :height="530" :data="temp.listStockSc" style="width: 100%"
							 border fit highlight-current-row v-loading="tempListLoading03">
								<el-table-column type="index" width="40" align="center"></el-table-column>
								<el-table-column prop="code" label="股票代码" align="center"></el-table-column>
								<el-table-column prop="name" label="股票名称" align="center"></el-table-column>
								<el-table-column label="相关度" align="center">
									<template slot-scope="scope">
										<el-rate v-model="scope.row.similar" :disabled='dialogStatus'></el-rate>
									</template>
								</el-table-column>
								<el-table-column v-if='!dialogStatus' align="center" label="操作" width="150" class-name="small-padding fixed-width">
									<template slot-scope="scope">
										<el-button style="width: auto" type="danger" size="mini" @click.native.prevent="deleteRow(scope.$index, temp.listStockSc)">删除</el-button>
									</template>
								</el-table-column>
							</el-table>
						</el-form-item>
						<el-dialog append-to-body title="相关股票" :visible.sync="dialogVisible" style="text-align: center"
						 :close-on-click-modal=false>
							<el-form-item label="查询股票" @keyup.enter.native="searchStock(stockSearch)">
								<el-input v-model="stockSearch" type="text" placeholder="请输入">
									<el-button slot="append" icon="el-icon-search" @keyup.enter.native="searchStock(stockSearch)" @click='searchStock(stockSearch)'></el-button>
								</el-input>
							</el-form-item>
							<el-transfer style="text-align: left; display: inline-block" v-model="transferData" :titles="['股票列表', '已选择']"
							 :button-texts="['移除', '添加']" :format="{noChecked: '${total}',hasChecked: '${checked}/${total}'}" @change="transferChange"
							 :data="stockLib">
							</el-transfer>
						</el-dialog>
					</el-col>
					<el-col :span="24">
						<el-form-item label="参考股票">
							<!-- temp.listStock.length > 10 ? 500 : 0 -->
							<el-table stripe :height="500" :data="temp.listStock" style="width: 100%"
							 border fit highlight-current-row v-loading="tempListLoading04">
								<el-table-column type="index" width="40" align="center"></el-table-column>
								<el-table-column prop="code" label="股票代码" align="center"></el-table-column>
								<el-table-column prop="name" label="股票名称" align="center"></el-table-column>
								<el-table-column label="相关度" align="center">
									<template slot-scope="scope">
										<el-rate v-model="scope.row.similar" disabled></el-rate>
									</template>
								</el-table-column>
							</el-table>
							<div class="pagination-container" style="margin-top: 10px;">
								<el-pagination background @size-change="scStocksSizeChange" @current-change="scStocksCurrentChange" :current-page.sync="scStocksObj.pageNum" :page-sizes="[10, 20, 30, 50]" :page-size="scStocksObj.pageSize" layout="total, sizes, prev, pager, next, jumper" :total="scStocksTotal"></el-pagination>
							</div>
						</el-form-item>
					</el-col>
				</el-row>
			</el-form>
			<div slot="footer" class="dialog-footer">
				<el-button v-if='!dialogStatus' type="success" @click="updateAuditData">提交并审核</el-button>
				<el-button type="primary" @click="dialogFormVisible = false">关闭</el-button>
			</div>
			<el-dialog append-to-body :fullscreen='true' :title="infoTitle" :visible.sync="dialogInfo">
				<div v-if='dialogInfo'>
					<infoPreview :infoMsg='infoMsg' @closeFile='closeFile'></infoPreview>
				</div>
			</el-dialog>
		</el-dialog>
	</div>
</template>

<script>
	import { articleStockList, getChartList } from '@/api/article'
	import {
		knowEvtList,
		knowEvtGet,
		evtUpdate,
		evtAudit,
		evtGetStatus,
		getAllTags,
		knowEvtDelete,
		cacelCluster,
		knowEvtAddHotList,
		knowEvtDeletList,
		selectByScNews,
		selectByNews,
		selectByScStock,
		selectByRelStock,
		delNews,
		listAllInfo
	} from '@/api/events'
	import waves from '@/directive/waves' // 水波纹指令
	import infoPreview from './infoPreview'

	export default {
		name: 'knownEvtManage',
		components: {
			infoPreview
		},
		directives: {
			waves
		},
		watch: {
			dialogFormVisible(val) {
				//  		this.$forceUpdate()
				if (!val) { //关闭弹窗
					this.fullscreenLoading = false
					this.temp.length = 0
				}
				this.$nextTick(() => {
					if(this.$refs['dataForm']){
						this.$refs['dataForm'].clearValidate()
					}
				})
			},
			'listQuery.chooseTime'(val) {
				if (val) {
					const endTime = new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate() + 1).getTime()
					this.updateTime = [endTime - 24 * 3600 * 1000 * val, endTime - 1000]
				} else {
					this.updateTime = ['', '']
				}
			},
			'listQuery.chooseTime2'(val) {
				if (val) {
					const endTime = new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate() + 1).getTime()
					this.publishTime = Object.assign([], [endTime - 24 * 3600 * 1000 * val, endTime - 1000])
				} else {
					this.publishTime = ['', '']
				}
			},
			updateTime(val) {
				this.listQuery.startTime = val[0] || ''
				this.listQuery.endTime = val[1] || ''
			},
			publishTime(val) {
				this.listQuery.shStartTime = val[0] || ''
				this.listQuery.shEndTime = val[1] || ''
			}
		},
		data() {
			return {
				tempData: {},
				multipleSelection: [],
				tableKey: 0,
				infoTitle: '',
				dialogInfo: false,
				infoMsg: {},
				list: null,
				total: null,
				listLoading: false,
				editLoading: false,
				refreshing: false,
				preview: false,
				previewContent: '',
				updateBtnLoading: false,
				tempListLoading01: false,
				tempListLoading02: false,
				tempListLoading03: false,
				tempListLoading04: false,
				tagOptions: [],
				updateTime: ['', ''],
				publishTime: ['', ''],
				listQuery: {
					pageNum: 1,
					pageSize: 10,
					eventHot: null,
          keyword: '',
					adjustStatus: '',
					dataStatus: '',
					eventTitle: '',
					chooseTime: '',
					chooseTime2: '',
				},
				filterPlateList: [],
				filterStockList: [],
				dialogVisible: false,
				showReviewer: false,
        flowChartList: [],
				stockSearch: '',
				temp: {
					createTime: "",
					originTime: '',
					creater: "",
					dataStatus: 0,
					eventAbs: "",
					eventDescript: "",
					eventHot: null,
					eventId: "",
					eventTitle: "",
					eventType: "",
					isOnline: "",
					listNews: "",
					listNewsInfo: [],
					listNewsInfoSc: [],
					listStock: [],
					listStockSc: [],
					listTags: [],
					newsNum: '',
					updateTime: '',
					updater: '',
					updatetime: ''
				},
				dialogFormVisible: false,
				dialogFormVisible2: false,
				dialogStatus: false,
				dialogPvVisible: false,
				stockLib: [],
				options0: [],
				options1: [],
				options2: [],
				pvData: [],
				rules: {
					eventTitle: [{
						required: true,
						message: '请输入...',
						trigger: 'change'
					}]
				},
				downloadLoading: false,
				image: '',
				searchBarVisable: false,
				notifyInfo: {
					startTime: new Date(),
					total: 0
				},
				fullscreenLoading: false,
				transferData: [],
				newsObj: {
					pageNum: 1,
					pageSize: 20,
					eventId: '',
					type: 1
				},
				stocksObj: {
					pageNum: 1,
					pageSize: 20,
					eventId: ''
				},
				scStocksObj: {
					pageNum: 1,
					pageSize: 20,
					eventId: ''
				},
				newsTotal: null,
				stocksTotal: null,
				scStocksTotal: null,
				dellNews: false,  //没点删除资讯
				evtId: '',
				tagList: [],  //懒加载中间件
				searchloading: false
			}
		},
		created() {
			this.getList()
			// this.init()
		},
		methods: {
			// init() {
			// 	getAllTags().then(res => {
			// 		let dta = res.Data || []
			// 		this.tagOptions = Object.assign([], dta)
			// 	})
			// },
			proving(e, tar) {
				let keynum = window.event ? e.keyCode : e.which
				if (keynum == 189 || keynum == 190 || keynum == 110 || keynum == 109) {
					this.$message({
						type: 'warning',
						message: '请输入正整数'
					})
					this.$set(e.target, 'value', '')
				}
			},
			selectShange(item) {
				this.$forceUpdate() //绑定了对象（需求如此），render函数没有自动更新，数据刷新了，但是视图没有刷新
			},
			addHotList() {
				let tar = this.multipleSelection.filter(e => e.dataStatus == 0 && e.adjustStatus == 1)
				if (tar.length === 0) {
					this.$message({	type: 'warning', message: '请勾选需要加入热点的已审核且未归档事件' })
					return
				}
				this.$confirm('确认加入热点，是否继续？', '提示', {
					confirmButtonText: '确定',
					cancelButtonText: '取消',
					type: 'warning'
				}).then(() => {
					let arr = tar.map(e => e.eventId)
					knowEvtAddHotList({
						batchIds: arr
					}).then(() => {
						this.getList()
						this.$notify({ title: '成功', message: '加入热点成功', type: 'success', duration: 2000 })
					})
				}).catch(() => {
					this.$message({ type: 'info', message: '已取消加入热点' })
				})
			},
			handleDeleteList() {
				let tar = this.multipleSelection.filter(e => e.adjustStatus == 1)
				if (tar.length === 0) {
					this.$message({ type: 'warning', message: '请勾选需要归档的已审核事件' })
					return
				}
				this.$confirm('确认归档，是否继续？', '提示', {
					confirmButtonText: '确定',
					cancelButtonText: '取消',
					type: 'warning'
				}).then(() => {
					let arr = tar.map(e => e.eventId)
					knowEvtDeletList({
						batchIds: arr
					}).then(() => {
						this.getList()
						this.$notify({
							title: '成功',
							message: '归档成功',
							type: 'success',
							duration: 2000
						})
					})
				}).catch(() => {
					this.$message({
						type: 'info',
						message: '已取消归档'
					})
				})
			},
			deleteRow(index, rows) {
				this.$confirm('确认删除, 是否继续?', '提示', {
					confirmButtonText: '确定',
					cancelButtonText: '取消',
					type: 'warning'
				}).then(() => {
					rows.splice(index, 1);
				}).catch(() => {
					this.$message({
						type: 'info',
						message: '已取消删除'
					})
				})
			},
			deleteNews(row){
				this.$confirm('确认删除, 是否继续?', '提示', {
					confirmButtonText: '确定',
					cancelButtonText: '取消',
					type: 'warning'
				}).then(() => {
					let obj = {
						'id': row.id
					}
					delNews(obj).then(res => {
						this.newsObj.type = 2
						this.getNewsList(this.evtId)
					})
				}).catch(() => {
					this.$message({ type: 'info', message: '已取消删除' })
				})
			},
			evtUpdateMethod() {
				this.updateBtnLoading = true
				evtUpdate(this.temp).then(res => {
					if (res.Data[0] == 0) {
						this.pollingMethod(this.temp)
					} else if (res.Data[0] == 1) {
						this.updateBtnLoading = false
						this.hasEnter = true
						this.$notify({
							title: '成功',
							message: '数据已更新',
							type: 'success',
							duration: 5000
						})
					}
				})
			},
			getNewsList(tar) {
				this.newsObj.eventId = tar
				selectByNews(this.newsObj).then(res => {
					this.tempListLoading01 = false
					this.temp.listNewsInfoSc = Object.assign([], res.Data)
					this.newsTotal = parseInt(res.total)
				})
			},
			newsSizeChange(val) {
				this.newsObj.pageSize = val
				this.getNewsList(this.evtId)
			},
			newsCurrentChange(val) {
				this.newsObj.pageNum = val
				this.getNewsList(this.evtId)
			},
			getStocksList(tar) {
				this.stocksObj.eventId = tar
				selectByScNews(this.stocksObj).then(res => {
					this.tempListLoading02 = false
					this.temp.listNewsInfo = Object.assign([], res.Data)
					this.stocksTotal = parseInt(res.total)
				})
			},
			stocksSizeChange(val) {
				this.stocksObj.pageSize = val
				this.getStocksList(this.evtId)
			},
			stocksCurrentChange(val) {
				this.stocksObj.pageNum = val
				this.getStocksList(this.evtId)
			},
			getScStock(tar) {
				this.scStocksObj.eventId = tar
				selectByScStock(this.scStocksObj).then(res => {
					this.tempListLoading04 = false
					this.temp.listStock = Object.assign([], res.Data)
					this.scStocksTotal = parseInt(res.total)
				})
			},
			scStocksSizeChange(val) {
				this.scStocksObj.pageSize = val
				this.getScStock(this.evtId)
			},
			scStocksCurrentChange(val) {
				this.scStocksObj.pageNum = val
				this.getScStock(this.evtId)
			},
			pollingMethod(data) {
				if (this.dialogFormVisible) {
					evtGetStatus(data).then(res => {
						if (res.Data[0] == 0) {
							let _this = this
							_this.dialogStatus = true
							_this.fullscreenLoading = true
							//	    				this.pollingMethod(data)
							setTimeout(function() {
								_this.pollingMethod(data)
							}, 1000)
						} else if (res.Data[0] == 1) {
							this.updateData(data)
							this.dialogStatus = false
							this.fullscreenLoading = false
							this.updateBtnLoading = false
							this.$notify({
								title: '成功',
								message: '数据更新完成',
								type: 'success',
								duration: 8000
							})
							return
						}
					})
				}
			},
			fresh(){
				this.newsObj = {
					pageNum: 1,
					pageSize: 20,
					eventId: '',
					type: 1
				},
				this.stocksObj =  {
					pageNum: 1,
					pageSize: 20,
					eventId: ''
				},
				this.scStocksObj = {
					pageNum: 1,
					pageSize: 20,
					eventId: ''
				},
				this.dialogFormVisible = true
				this.tempListLoading01 = true
				this.tempListLoading02 = true
				this.tempListLoading03 = true
				this.tempListLoading04 = true
			},
			handleShow(row, boo) { //点击开始轮询调接口，并显示老数据 不显示操作按钮，提示数据正在生成中，轮询到1时更新数据，显示操作按钮，点击更新资讯循环这个操作
				this.fresh()
				this.dialogStatus = boo
				this.evtId = row.eventId
				knowEvtGet(row).then(res => {
					this.temp = Object.assign({}, res.Data[0])
					this.temp.listTags = this.temp.listTags.map(e => {return e.keyword})
					// this.temp.sjStyle = '已知'
					// this.temp.tsqt = '关注用户推送'
					this.getNewsList(row.eventId)
					this.getStocksList(row.eventId)
					this.getScStock(row.eventId)
					selectByRelStock({eventId: row.eventId}).then(res => {
						this.tempListLoading03 = false
						this.temp.listStockSc = Object.assign([], res.Data)
					})
					this.$nextTick(() => {
						if(this.$refs['dataForm']){
							this.$refs['dataForm'].clearValidate()
						}
					})
				})
				if(!boo && this.tagList.length == 0) this.getSelectList()
			},
			getSelectList() {
				listAllInfo().then(res => {
					this.tagList = res.Data[0]
				})
        getChartList().then(res => {
        	this.flowChartList = res.Data
        })
			},
			remoteMethod(query) {
			  if (query !== '') {
			    this.searchloading = true;
			    setTimeout(() => {
			      this.searchloading = false;
			      this.tagOptions = this.tagList.filter(item => {
					return item.toLowerCase().indexOf(query.toLowerCase()) > -1;
			      });
			    }, 200);
			  } else {
			    this.tagOptions = [];
			  }
			},
			handleSelectionChange(val) {
				this.multipleSelection = val
			},
			handleSelect() {
				this.stockSearch = ''
				this.stockLib = this.temp.listStockSc.map(e => {
					return {
						key: e.name + '(' + e.code + ')',
						label: e.name + '(' + e.code + ')',
						similar: e.similar || 0
					}
				})
				this.transferData = this.temp.listStockSc.map(e => {
					return e.name + '(' + e.code + ')'
				})
				this.dialogVisible = true
			},
			transferChange(value, direction, movedKeys) { //当前值， 数据移动的方向， 发生移动的数据key数组
				if (direction == 'right') {
					movedKeys.map(tar => {
						let obj = {
							code: tar.substring(tar.indexOf("(") + 1, tar.indexOf(")")),
							name: tar.split('(')[0],
							similar: 0
						}
						return this.temp.listStockSc.push(obj)
					})
				} else if (direction == 'left') {
					movedKeys.forEach(val => {
						let valcode = val.substring(val.indexOf("(") + 1, val.indexOf(")"))
						this.temp.listStockSc.forEach((item, index) => {
							if (item.code == valcode) {
								this.temp.listStockSc.splice(index, 1);
							}
						})
					})
				}
			},
			searchStock(e) {
				if (e.trim() === '') {
					this.$message({
						type: 'warning',
						message: '请输入有效查询内容！'
					})
					return
				}
				const params = {
					pageNum: 1,
					pageSize: 99999,
					phoneticChars: e
				}
				articleStockList(params).then(response => {
					const stocks = []
					this.stockLib = []
					this.temp.listStockSc.forEach(e => {
						stocks.push(e.code)
						this.stockLib.push({
							key: e.name + '(' + e.code + ')',
							label: e.name + '(' + e.code + ')',
							similar: e.similar
						})
					})
					response.Data.map(e => {
						if (stocks.indexOf(e.code) === -1) {
							if(e.name.indexOf('(') === -1){
								this.stockLib.push({
									key: e.name + '(' + e.code + ')',
									label: e.name + '(' + e.code + ')',
									similar: 0
								})
							} else {
								let Bname = e.name.replace('(', '[')
								Bname = Bname.replace(')', ']')
								this.stockLib.push({
									key: Bname + '(' + e.code + ')',
									label: Bname + '(' + e.code + ')',
									similar: 0
								})
							}
						}
					})
				})
			},
			updateAuditData() {
				this.$refs['dataForm'].validate(valid => {
					if (valid) {
						let obj = Object.assign({}, this.temp)
						obj.listTags = obj.listTags.map(e => {return { 'keyword': e, 'type': 1 }})
						delete obj.listNewsInfoSc
						delete obj.listNewsInfo
						delete obj.listStock
						evtAudit(obj).then(() => {
							this.getList()
							this.dialogFormVisible = false
							this.$notify({ title: '成功', message: '审核成功', type: 'success', duration: 5000 })
						})
					} else {
						console.log('error submit!!');
						return false;
					}
				})
			},
			stateColor(data) {
				switch (data) {
					case 0:
						return 'success' // '正常'
					case 2:
						return 'danger' // '已归档'
				}
			},
			stateFont(data) {
				switch (data) {
					case 0:
						return '正常'
					case 2:
						return '已归档'
				}
			},
			formatClass(data) {
				switch (data) {
					case 0:
						return 'warning' // '未审核'
					case 1:
						return 'success' // '已审核'
				}
			},
			formatStatu(data) {
				switch (data) {
					case 0:
						return '未审核'
					case 1:
						return '已审核'
				}
			},
			attitudeTagColor(num) {
				switch (num) {
					case -1:
						return 'success'
					case 0:
						return ''
					case 1:
						return 'danger'
				}
			},
			attitudeTag(num) {
				switch (num) {
					case -1:
						return '利空'
					case 0:
						return '中性'
					case 1:
						return '利好'
				}
			},
			showInfo(row) {
				if(row.srcType == 1 || row.srcType == 2){
					this.infoMsg = Object.assign({}, row)
          if(this.infoMsg.newsId) this.infoMsg.id = this.infoMsg.newsId
					this.infoTitle = '资讯详情'
					this.dialogInfo = true
				} else {
					this.$message({ type: 'info', message: '获取资讯标识失败' })
				}
			},
			closeFile() {
				this.dialogInfo = false
			},
			getList() {
				this.listLoading = true
				const params = Object.assign({}, this.listQuery)
				if (!params.eventHot) params.eventHot = null
				knowEvtList(params).then(res => {
					this.listLoading = false
					this.list = res.Data
					this.total = parseInt(res.total)
				})
			},
			resetForm() {
				let obj = {
					pageNum: 1,
					pageSize: 20,
					adjustStatus: '',
					dataStatus: '',
					eventTitle: '',
					chooseTime: '',
					chooseTime2: '',
					eventHot: null
				}
				this.listQuery = Object.assign({}, obj)
			},
			handleSizeChange(val) {
				this.listQuery.pageSize = val
				this.getList()
			},
			handleCurrentChange(val) {
				this.listQuery.pageNum = val
				this.getList()
			},
			handleDelete(row) {
				this.$confirm('确认归档, 是否继续?', '提示', {
					confirmButtonText: '确定',
					cancelButtonText: '取消',
					type: 'warning'
				}).then(() => {
					let obj = {
						id: row.id
					}
					knowEvtDelete(obj).then(() => {
						this.$notify({
							title: '成功',
							message: '归档成功',
							type: 'success',
							duration: 2000
						})
						this.getList()
					})
				}).catch(() => {
					this.$message({
						type: 'info',
						message: '已取消归档'
					})
				})
			},
			dataStatusChange(row) {
				this.$confirm('确认取消归档, 是否继续?', '提示', {
					confirmButtonText: '确定',
					cancelButtonText: '取消',
					type: 'warning'
				}).then(() => {
					let obj = {
						id: row.id
					}
					cacelCluster(obj).then(() => {
						this.$notify({
							title: '成功',
							message: '取消归档成功',
							type: 'success',
							duration: 2000
						})
						this.getList()
					})
				}).catch(() => {
					this.$message({
						type: 'info',
						message: '已取消'
					})
				})
			}
		}
	}
</script>

<style scoped>
	.el-tag {
		margin-right: 5px;
	}
	.tagColor {
		color: white;
		border-radius: 5px;
	}
</style>
